using System;
using Xtensive.Orm;

namespace SalesPoint.Model
{
  [TableMapping("Categories")]
  [HierarchyRoot]
  public class Category : Entity
  {
    [Field, FieldMapping("CategoryId"), Key]
    public int Id { get; private set; }

    [Field(Length = 15, Indexed = true)]
    public string CategoryName { get; set; }

    [Field]
    public string Description { get; set; }

    [Field(LazyLoad = true, Length = Int32.MaxValue)]
    public byte[] Picture { get; set; }

    [Field]
    [Association(PairTo = "Category", OnOwnerRemove = OnRemoveAction.Clear, OnTargetRemove = OnRemoveAction.Clear)]
    public EntitySet<Product> Products { get; private set; }

    public Category(Session session)
      :base(session)
    {
    }
  }
}